package com.peppa.xtext.esaml.tests;

import com.google.inject.Inject;
import com.peppa.xtext.esaml.esaml.Model;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.resource.SaveOptions;
import org.eclipse.xtext.serializer.ISerializer;
import org.eclipse.xtext.testing.InjectWith;
import org.eclipse.xtext.testing.extensions.InjectionExtension;
import org.eclipse.xtext.testing.util.ParseHelper;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.Extension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

@ExtendWith(InjectionExtension.class)
@InjectWith(ESAMLInjectorProvider.class)
@SuppressWarnings("all")
public class ESAMLFormatingTest {
  @Inject
  @Extension
  private ParseHelper<Model> _parseHelper;

  @Inject
  @Extension
  private ISerializer _iSerializer;

  public String format(final String str) {
    try {
      return this._iSerializer.serialize(this._parseHelper.parse(str), SaveOptions.newBuilder().format().getOptions());
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
  }

  @Test
  public void pattern() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("\t\t");
    _builder.append("system SystemType\t\t\tfeatures\t\t\t\toutput data port inputDataPort ;\t\t\t\trequire data access requireDataAccess ;");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("properties\t\t\t\tstateval bool variableName ;\t\tend\t\tsubsystem SubSystemType\t\t\tproperties\t\t\t\tbool & ref -> system SystemType variableName ;");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("end\t\tsystem implementation SystemType . systemImpl\t\tend");
    _builder.newLine();
    final String str = _builder.toString();
    System.out.println(this.format(str));
  }
}
